using System;
using System.Text;
using System.Collections;
using System.Collections.Generic;

using SlimDX;
using SlimDX.Direct3D9;

using miciv.Rendering;

namespace miciv.Geometry
{
    abstract public class ShapeBase : IShape
    {
        protected VertexDefinition m_vertexDefinition;
        protected UserDataOverrideHandler m_userDataOverride;
        protected Vector3 m_f3Size;
        protected int m_sLevelOfDetail;
        protected IShapeVertex[] m_arrayVertex;
        protected List<IShapeTopology> m_lstTopology;

        public ShapeBase()
        {
            this.m_vertexDefinition = null;
            this.m_userDataOverride = null;
            this.m_f3Size = new Vector3(1.0f, 1.0f, 1.0f);
            this.m_sLevelOfDetail = 1;
            this.m_arrayVertex = null;
            this.m_lstTopology = new List<IShapeTopology>();
        }

        #region IShape Members

        public VertexDefinition VertexDefinition
        {
            get
            {
                return this.m_vertexDefinition;
            }
            set
            {
                this.m_vertexDefinition = value;
            }
        }

        public UserDataOverrideHandler UserDataOverride
        {
            get
            {
                return this.m_userDataOverride;
            }
            set
            {
                this.m_userDataOverride = value;
            }
        }

        public Vector3 Size
        {
            get
            {
                return this.m_f3Size;
            }
            set
            {
                this.m_f3Size = value;
            }
        }

        public int LevelOfDetail
        {
            get
            {
                return this.m_sLevelOfDetail;
            }
            set
            {
                this.m_sLevelOfDetail = value;
            }
        }

        public int VertexCount
        {
            get
            {
                if (null != this.m_arrayVertex)
                {
                    return this.m_arrayVertex.Length;
                }
                return 0;
            }
        }

        public int TopologyCount
        {
            get
            {
                return this.m_lstTopology.Count;
            }
        }

        abstract public bool Build(UserDataOverrideHandler _handler);

        public IEnumerable<IShapeVertex> Vertices
        {
            get
            {
                return this.m_arrayVertex;
            }
        }

        public IEnumerable<IShapeTopology> Topologies
        {
            get
            {
                return this.m_lstTopology;
            }
        }

        #endregion
    }
}
